package com.tanhua.server.controller;

import com.tanhua.server.paramPojo.LocationInfo;
import com.tanhua.server.service.BaiduService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author feihao
 * @version 1.0
 * @date 2021/7/8 16:31
 */
//百度上传位置信息接口：
@RestController
@RequestMapping("/baidu/location")
@Slf4j
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    @PostMapping
    public ResponseEntity<Void> sendLocation(@RequestBody LocationInfo locationInfo) {


        try {
            Boolean b = baiduService.updateLocation(locationInfo);
            if (b) {
                return ResponseEntity.ok(null);
            }
        } catch (Exception e) {
            log.error("上报位置信息失败，locationInfo" + locationInfo, e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
